/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.asportoonline.configuration;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletConfig;
/**
 *
 * @author Valerio Costmagna <costamagna.valerio@gmail.com>
 */
public class Configuration {
    	//private static final Logger logger = Logger.getLogger(Configuration.class);

	protected static Properties views;
	protected static Properties actions;

	public static void init(ServletConfig config)
	{
		String actionFile = config.getServletContext().getRealPath("WEB-INF/actions.properties");
		String viewFile = config.getServletContext().getRealPath("WEB-INF/views.properties");

		views = new Properties();
		actions = new Properties();

		try {
			views.load(new FileInputStream(viewFile));
			actions.load(new FileInputStream(actionFile));
		} catch (FileNotFoundException e) {
			//logger.error("Non trovato un file di configurazione",e);
		} catch (IOException e) {
			//logger.error("Impossibile leggere un file di configurazione",e);
		}

		//logger.info("Caricate "+actions.size()+" actions e "+views.size()+" views");
	}

	public static String getViewPage(String view) {
		return views.getProperty(view);
	}

	public static String getAction(String action) {
		return actions.getProperty(action);
	}

}
